package com.guoyh.xprodatas.service.wmodel.project

import com.guoyh.baserepos.entity.base.ApiPagerResponse
import com.guoyh.baserepos.entity.wmodel.ArticleBean
import com.guoyh.baserepos.entity.wmodel.ProjectTabBeanItem
import com.guoyh.pronet.service.BaseService
import rxhttp.IAwait
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

/**
 * @CreateDate: 7/29/21 11:30 AM
 * @Author: guoyh
 * @Description: java类作用描述
 */

val wModelProjectApi by lazy {
    WMProjectApiService.instance
}

class WMProjectApiService private constructor() : BaseService() {

    companion object {
        const val PROJECT_TAB = "project/tree/json"
        const val PROJECT_LIST = "project/list/%s/json"

        val instance: WMProjectApiService by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            WMProjectApiService()
        }

    }

    /**
     * 获取项目全部分类
     */
    fun getProjectTab(): IAwait<MutableList<ProjectTabBeanItem>> {
        return RxHttp.get(PROJECT_TAB)
            .toResponse()
    }

    /**
     * 获取项目某一分类下的 列表
     */
    fun getProjectList(pageIndex: Int,cid:String): IAwait<ApiPagerResponse<ArticleBean>> {
        return RxHttp.get(PROJECT_LIST, pageIndex)
            .add("cid",cid)
            .toResponse()
    }

}